package com.justech.tcp.server.parse;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author feifei.li
 */
public class StringArrayList<E> extends ArrayList<E> implements List<E> {

    @Override
    public String toString() {

        Iterator<E> it = iterator();
        if (!it.hasNext()) {
            return "[]";
        }

        StringBuilder sb = new StringBuilder();
        sb.append('[');
        for (; ; ) {
            E e = it.next();
            sb.append(e == this ? "(this Collection)" : "\"" + e + "\"");
            if (!it.hasNext()) {
                return sb.append(']').toString();
            }
            sb.append(',').append(' ');
        }
    }
}
